/*
 * @Description: 
 * @Author: HKH
 * @Date: 2024-09-03 11:37:17
 * @LastEditors: HKH
 * @LastEditTime: 2024-09-03 15:10:44
 */
import java.util.Random;
import java.util.Scanner;
public class TestGuessNumber {
    public static void main(String[] args) {
        System.out.println("请输入猜测的数字：");
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        int randomNumber = random.nextInt(100) + 1;
        System.out.println("随机生成的数字为：" + randomNumber);
        while (true) {
            System.out.println("请输入1-100之间的数字：");
            int sz = sc.nextInt();
            if (sz < 1 || sz > 100) {
                System.out.println("输入的数字不在1-100之间，请重新输入！");
            }else {
                if(sz>randomNumber){
                    System.out.println("猜大了，请再试一次！");
                    continue;

                }else if(sz<randomNumber){
                    System.out.println("猜小了，请再试一次！");
                    continue;
                }else{
                    System.out.println("恭喜你，猜对了！");
                    break;
                }
            }
        }
    }
}